package twoPointers;

public class happyNums {
    public int numsadd(int n){
        int sum=0;
        while(n>0){
            int m=n%10;
            sum=sum+m*m;
            n/=10;
        }
        return sum;
    }
    public boolean isHappy(int n) {
        int fast=numsadd(n);
        int slow=n;
        while(fast!=slow){
            fast=numsadd(numsadd(fast));
            slow=numsadd(slow);
        }
        return fast==1;
    }
}
